﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for Users
/// </summary>
public class UsersRepository
{
    private Up1VNDataContext db;
    public UsersRepository()
	{
        db = new Up1VNDataContext();
	}

    public int GetUserIdByName(string username)
    {
        var a= (from o in db.Users where String.Equals(o.Users_Name,username) select o).SingleOrDefault();
        return (int)a.Users_Id;
    }
    public int GetIdByEmailOrUsername(string user_email)
    {
        return (int)(from o in db.Users where String.Equals(o.Users_Name, user_email) || String.Equals(o.Users_Email, user_email) select o).SingleOrDefault().Users_Id;
    }
    public string GetEmailById(int userId)
    {
        return (from o in db.Users where o.Users_Id == userId select o).SingleOrDefault().Users_Email;
    }
}